package com.chen.common.security.component;

import com.chen.base.inter.CurrUserInter;
import com.chen.common.security.info.UserInfo;
import com.chen.common.security.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;

/**
 * @author: ~龙~
 * @date: 2023/8/15 16:53
 **/
@Slf4j
@Component
@ConditionalOnMissingBean(CurrUserInter.class)
public class SecuritySqlCurrUser implements CurrUserInter {

    @Override
    public String currUserId() {
        UserInfo info = SecurityUtils.getUser();
        return info != null ? info.getUserId().toString() : "0";
    }
}
